#!/bin/bash
red=$(tput setaf 1)
green=$(tput setaf 2)
reset=$(tput sgr0)
echo  "${green}--------- git 提交预检测 ---------${reset}"

for FILE in $(git diff --name-only --cached)
do
    if [[ $FILE == *".sh"* ]] || [[ $FILE == *"public/static/"* ]] || [[ $FILE == *"iconfont.js"* || $FILE == *".config.js"* || $FILE == *"min.js"* ]]
    then
        continue
    fi
    # shellcheck disable=SC2069
    grep 'debugger\|' "$FILE" 2>&1 >/dev/null
    # shellcheck disable=SC2181
    if [ $? -eq 0 ]
    then
        echo "$red" "$FILE" '包含 TODO/debugger/console/alert 请完全删除后提交(注释也不可以哦😯)'
        exit 1
    fi
done
exit